/**
 * 
 */
package cn.ivicar.passport.controller.utils;

/**
 * @Author: liurunbin
 * @Description:性别枚举类
 * @Date: Created in 2017/5/22
 */
public enum SexEnum {

	FEMALE(0, "女"), MAN(1, "男");

	private int index;
	private String value;

	SexEnum(int index, String value) {
		this.index = index;
		this.value = value;
	}

	public int getIndex() {
		return index;
	}

	public String getValue() {
		return value;
	}

	public static SexEnum get(int index) {
		switch (index) {
		case 0:
			return FEMALE;
		case 1:
			return MAN;
		default:
			return null;
		}
	}

	public static SexEnum get(String code) {

		if (FEMALE.getValue().equalsIgnoreCase(code)) {
			return FEMALE;
		} else if (MAN.getValue().equalsIgnoreCase(code)) {
			return MAN;
		} else {
			return null;
		}
	}

}
